using System;
using System.Collections.Generic;
using System.Text;
using Csla;
using System.Data;
using Csla.Data;

namespace Active.Core
{
    /// <summary>
    /// The read only Brokerage infomation.
    /// </summary>
    [Serializable()]
    public class BrokerageInfo : ReadOnlyBase<BrokerageInfo>
    {
        #region Business Methods

        // TODO: add your own fields, properties and methods
        private int _id;
        /// <summary>
        /// Gets the id.
        /// </summary>
        /// <value>The id.</value>
        public int Id
        {
            get { return _id; }
        }

        private decimal _payValue;

        public decimal PayValue
        {
            get { return _payValue; }
        }
        private DateTime _submitDate;

        public DateTime SubmitDate
        {
            get { return _submitDate; }
        }
        private string _submitUser = string.Empty;

        public string SubmitUser
        {
            get { return _submitUser; }
        }
        private int _ownerId;

        public int OwnerId
        {
            get { return _ownerId; }
        }
        private string _description = string.Empty;

        public string Description
        {
            get { return _description; }
        }

        protected override object GetIdValue()
        {
            return _id;
        }

        #endregion

        #region Factory Methods

        internal static BrokerageInfo GetBrokerageInfo(SafeDataReader dr)
        {
            return new BrokerageInfo(dr);
        }

        private BrokerageInfo()
        { /* require use of factory methods */ }

        private BrokerageInfo(SafeDataReader dr)
        {
            Fetch(dr);
        }

        #endregion

        #region Data Access

        private void Fetch(SafeDataReader dr)
        {
            _id = dr.GetInt32("Id");
            _description = dr.GetString("Description");
            _ownerId = dr.GetInt32("OwnerId");
            _payValue = dr.GetDecimal("PayValue");
            _submitDate = dr.GetDateTime("SubmitDate");
            _submitUser = dr.GetString("SubmitUser");
        }

        #endregion
    }
}

